<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
		<div class="center">
			<div class="col-main">
				<div class="main-wrap" style="background-color:white;">
					<div class="am-cf am-padding">
						<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">修改安全问题</strong> / <small>Set&nbsp;Safety&nbsp;Question</small></div>
					</div>
					<hr/>
					<!--进度条-->
					<div class="m-progress">
						<div class="m-progress-list">
							<span class="step-1 step">
                                <em class="u-progress-stage-bg"></em>
                                <i class="u-stage-icon-inner">1<em class="bg"></em></i>
                                <p class="stage-name">设置安全问题</p>
                            </span>
							<span class="step-2 step">
                                <em class="u-progress-stage-bg"></em>
                                <i class="u-stage-icon-inner">2<em class="bg"></em></i>
                                <p class="stage-name">完成</p>
                            </span>
							<span class="u-progress-placeholder"></span>
						</div>
						<div class="u-progress-bar total-steps-2">
							<div class="u-progress-bar-inner"></div>
						</div>
					</div>
					<form class="am-form am-form-horizontal" action="${pageContext.request.contextPath }/user/savequestion" id="form">
						<div class="am-form-group select">
							<label for="user-question1" class="am-form-label">旧问题</label>
							<div class="am-form-content">
								<select data-am-selected>
									<option value="${user.q_id}" selected>${user.questionName}</option>
								</select>
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-answer1" class="am-form-label">答案</label>
							
							<div class="am-form-content">
								<input type="text" id="user-answer1" placeholder="请输入安全问题答案" name="answer" value="">
								<span id="span" value=""></span>
							</div>
						</div>
						<div class="am-form-group select">
							<label for="user-question2" class="am-form-label">新问题</label>
							<div class="am-form-content">
								<select data-am-selected name="questionId">
									<option value="" selected>请选择安全问题</option>
									<c:forEach var="question" items="${question}">
										<option value="${question.q_id}">${question.questionName}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-answer2" class="am-form-label">答案</label>
							<div class="am-form-content">
								<input type="text" id="user-answer2" placeholder="请输入安全问题答案" name="newanswer" required="required">
							</div>
						</div>
						<div class="info-btn">
							<button type="submit" id="submit" class="am-btn am-btn-danger">保存修改</button>
							<span style="color:red;">${error}</span>
						</div>

					</form>
					</div>
				</div>
<%@include file="common/footer.jsp"%>
</div>
  </body>
  <script>
  	$("#user-answer1").on("blur",function(){
  		var _answer = $(this).val();
  		$.ajax({
  			url : "/Trip/user/judgequestion",
  			data : {answer:_answer},
  			dataType : "json",
  			type : "POST",
  			success : function(data){
  				if(data == "success"){
  					$("#span").val("1");
  				}else{
  					alert("问题不匹配! 请重新输入!");
  					$("#span").val("");
  				}
  			}
  		
  		});
  	});
  	
  	$("#submit").on("click",function(){
  		var span = $("#span").val();
  		if(span == "" || span == null){
  			alert("请填写正确的旧答案!!!");
  		}else{
  			$("#form").submit();
  		}
  	});
  </script>
</html>
